package algotithm.interview.baidu.test2;

import java.io.*;

/**
 * @author zhouyanxiang
 * @Date 2021-03-2021/3/17-19:51
 */
public class Main {

    private static int N = 110;
    private static int[]p = new int[N];
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

        String[] arr1 = reader.readLine().split(" ");
        int n = Integer.parseInt(arr1[0]);
        int m = Integer.parseInt(arr1[1]);
        int k = Integer.parseInt(arr1[2]);

        int t = m;
        for (int i = 1; i <= n; i++) {
            p[i] = i;
        }
        while(t-- > 0) {
            String[] arr = reader.readLine().split(" ");
            int u = Integer.parseInt(arr[0]);
            int v = Integer.parseInt(arr[1]);
            int fu = find(u);
            int fv = find(v);
            if (fu != fv) {
                p[fu] = fv;
                fu = p[fv];
            }
        }
        int[] res = {1,2,3};
        for (int i = 0 ; i < res.length; i++) {
            writer.write(res[i] + " ");
        }
        writer.write("\n");
        writer.flush();
        writer.close();
        reader.close();
    }

    public static int find(int x) {
        if (x != p[x]) {
            p[x] = p[p[x]];
            x = p[x];
        }
        return x;
    }
}
